package com.ThreadStudy.syn;

/*
* 线程不安全的集合
*
*
* */

import java.util.ArrayList;
import java.util.List;

public class UnSafeList {
    public static void main(String[] args) throws InterruptedException {
        List<String> list = new ArrayList<>();
        for (int i = 0; i < 1000; i++) {
            new Thread(()->{
                list.add(Thread.currentThread().getName());
            }).start();
            
        }
        Thread.sleep(2000);
        System.out.println(list.size());  // 999
    }
}
